home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE08 / DATADICT / SETUP.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-05-07  |  1.3 KB  |  31 lines

  1. program Setup;
  2. { This is a stub program designed to copy the "real" install program to }
  3. { the hard disk, run the install, then terminate itself. }
  4. uses SysUtils, Utils, Dialogs, WinTypes, WinProcs;
  5.  
  6. const
  7.   ErrFailSpawn = 'Fatal Error: Failed to spawn INST.EXE. Error code: %d';
  8.   ErrFailCopy  = 'Fatal Error: Failed to copy files to temp directory';
  9.  
  10. var
  11.   S: String;
  12.   a: array[0..255] of char;
  13.   WEReturn: word;
  14. begin
  15.   S := GetEnvVar('temp');                          { find temp directory }
  16.   if S = '' then S := 'c:\';                       { use root if none exists }
  17.   S := AddBackSlash(S);
  18.   try
  19.     CopyFile('inst.exe', S + 'inst.exe');          { copy install program }
  20.     CopyFile('ddgsetup.ini', S + 'ddgsetup.ini');  { copy ini file }
  21.   except
  22.     on EInOutError do begin                        { if error copying files, }
  23.       MessageDlg(ErrFailCopy, mtError, [mbOk], 0); { show message }
  24.       Raise;                                       { reraise exception to exit }
  25.     end;
  26.   end;
  27.   StrPCopy(a, S + 'inst.exe foobar ' + ExtractFilePath(ParamStr(0)));
  28.   WEReturn := WinExec(a, sw_ShowNormal);           { execute install from HD }
  29.   if WEReturn < 32 then                            { show error if exec fails }
  30.     MessageDlg(Format(ErrFailSpawn, [WEReturn]), mtError, [mbOk], 0);
  31. end.